home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-09-21 | 7.1 KB | 172 lines | [TEXT/PJMM] |
- unit SAT;
-
- interface
-
- type
- {BMPtr = ^BitMap;}
-
- FacePtr = ^Face;
- Face = record
- colorData: Ptr;
- resNum: integer;
- iconMask: BitMap;
- rowBytes: integer;
- next: FacePtr;
- maskRgn: RgnHandle;
- end;
-
- SpritePtr = ^Sprite;
- Sprite = record
- { Variables that you should change as appropriate }
- kind: Integer; { Used for identification. >0: friend. <0 foe }
- position: Point;
- hotRect, hotRect2: Rect; { Tells how large the sprite is; hotRect is centered around origo }
- {hotRect is set by you. hotrect2 is set by SAT - forget about it}
- face: FacePtr; { Pointer to the Face (appearance) to be used. }
- task: ProcPtr; { Callback-routine, called once per frame. If task=nil, the sprite is removed. }
- hittask: ProcPtr; { Callback in collisions. }
- { SAT variables that you shouldn't change: }
- oldpos: point; { The 'task' routine is not allowed to change this! }
- next, prev: SpritePtr;
- r, oldr: Rect;
- { Variables for internal use by the sprites. Use as you please. }
- layer: integer; {For free use, or for sorting.}
- speed: Point; { Can be used for speed, but not necessarily. }
- mode: integer; { Usually used for different modes and/or to determine what image to show next. }
- appPtr: Ptr; {Pointer for use by the application - i.e. pointer to extra data}
- appLong: Longint; {Longint for free use by the application.}
- end;
-
- {Type for SATs pattern utilities.}
- type
- SATPattern = record
- patternType: integer; {1 = Pattern, PatHandle, 2 = PixPat, PixPatHandle}
- thePat: PixPatHandle; {or PatHandle}
- end; {record}
- SATPatPtr = ^SATPattern;
- SATPatHandle = ^SATPatPtr;
-
-
- {Temp}
- UpdatePtr = ^UpdateRec;
- UpdateRec = record
- updateRect: Rect;
- next: UpdatePtr;
- end;
-
- {Configuration types: VPositionSort and KindCollision are defaults.}
- {SortType = (VPositionSort, LayerSort, NoSort);}
- {CollisionType = (KindCollision, ForwardCollision, BackwardCollision, NoCollision);}
-
- const
- {Sorting options}
- VPositionSort = 0;
- LayerSort = 1;
- NoSort = 2;
- {Collision detection options}
- KindCollision = 0;
- ForwardCollision = 1;
- BackwardCollision = 2;
- NoCollision = 3;
-
- var
- {$J+}
- SATwind: WindowPtr; { The window that SAT draws in. }
-
- offScreen: GrafPtr; { Offscreen image }
- backScreen: GrafPtr; { Background image }
- offScreenGD, BackScreenGD: GDHandle; {Graphic devices for offScreen and BackScreen}
-
- ox, oy: Longint; { Origin-variables for PlotFast }
- SATpict, SATbwpict: integer;
- sRoot: SpritePtr; {Root of the sprite list}
-
- offSizeH, offSizeV: integer; {Size of the animation area}
-
- { Screen size parameters. }
- { Usually, you will only need to inspect offSizeH and offSizeV, and sometimes ourDepth and colorFlag }
- {The others are subject to change or go away}
- ourDevice: GDHandle;
- ourScreen: PixMapHandle;
- ourBaseAddr: Ptr;
- ourRowBytes: Integer;
- ourBounds: Rect;
- ourDepth: Integer; { Depth of screen and offscreens }
- colorFlag: Boolean; { Is this Mac color capable? }
- anyMonsters: Boolean; { False when no sprites with kind < -1 are active }
-
- updateRoot: UpdatePtr; {temp}
- {$J-}
-
- {Initializing and customizing}
- procedure ConfigureSAT (PICTfit: boolean; newSorting, newCollision, searchWidth: integer);
- function InitSAT (pictID, bwpictID, Xsize, Ysize: integer): WindowPtr;
- function CustomInitSAT (pictID, bwpictID: integer; SATdrawingArea: Rect; preloadedWind: WindowPtr; chosenScreen: GDHandle; useMenuBar, centerDrawingArea, fillScreen, dither4bit: Boolean): WindowPtr;
- {Maintainance, background manipulation etc.}
- function SATDepthChangeTest: Boolean;
- procedure SATDrawPICTs (pictID, bwpictID: integer);
- procedure PeekOffscreen;
- {Drawing}
- procedure SATPlotFace (theFace: FacePtr; theGrafPtr: GrafPtr; theGDevice: GDHandle; where: Point; fast: boolean);
- procedure SATPlotFaceToScreen (theFace: FacePtr; where: Point; fast: boolean); {*NEW*}
- procedure SATCopyBits (src, dest: GrafPtr; destGD: GDHandle; srcPt, destPt: Point; width, height: integer; fast: Boolean);
- procedure SATCopyBitsToScreen (src: GrafPtr; srcPt, destPt: Point; width, height: integer; fast: Boolean); {*NEW*}
- procedure SATBackChanged (r: Rect); {Tell SAT about changes in BackScreen}
- procedure SATSetPortOffScreen; {Use before using QuickDraw on offScreen}
- procedure SATSetPortBackScreen; {Use before using QuickDraw on BackScreen}
- procedure SATSetPortScreen; {Use to restore after drawing off/backscreen}
- {Sprite handling}
- function GetFace (resNum: integer): FacePtr;
- procedure DisposeFace (theFace: FacePtr);
- function NewSprite (kind, hpos, vpos: integer; callback, setup, hittask: ProcPtr): SpritePtr;
- function NewSpriteAfter (afterthis: SpritePtr; kind, hpos, vpos: integer; callback, setup, hittask: ProcPtr): SpritePtr;
- procedure KillSprite (who: Spriteptr);
- {Animating}
- procedure RunSAT (fast: Boolean); {The heart of the whole package!}
- {Menu bar}
- procedure ShowMBar;
- procedure HideMBar (wind: WindowPtr);
- {Special functions for advanced programmers}
- procedure SATInstallSynch (theSynchProc: ProcPtr);
- procedure SATInstallEmergency (theEmergencyProc: ProcPtr);
- procedure SATSetSpriteRecSize (theSize: longint);
- procedure SkipSAT;
- procedure KillSAT; {Dispose of offscreen buffers to allow re-init}
- {Offscreen - use only if you need an *extra* offscreen buffer. These calls are likely to change in the future!}
- procedure SATMakeOffscreen (var portP: GrafPtr; rectP: Rect; var retGDevice: GDHandle); {Make offscreen buffer in current screen depth and CLUT.}
- procedure SATDisposeOffScreen (portP: GrafPtr; theGDevice: GDHandle); {Get rid of offscreen}
- function CreateOffScreen (bounds: Rect; depth: Integer; colors: CTabHandle; var retPort: CGrafPtr; var retGDevice: GDHandle): OSErr; {From Principia Offscreen - color only}
- procedure DisposeOffScreen (doomedPort: CGrafPtr; doomedGDevice: GDHandle);{From Principia Offscreen - color only}
-
- {Utilities}
- procedure DrawInt (i: integer);
- procedure DrawLong (l: longint);
- function Rand (n: integer): integer;
- function Rand10: integer;
- function Rand100: integer;
- procedure ReportStr (str: str255);
- function QuestionStr (str: str255): Boolean;
- procedure CheckNoMem (p: Ptr); {Might replace this by SATnewPtr}
- procedure SetMouse (where: point);
- {Pattern utilities}
- procedure SATPenPat (SATpat: SATPatHandle);
- procedure SATBackPat (SATpat: SATPatHandle);
- function SATGetPat (patID: integer): SATPatHandle;
- procedure SATDisposePat (SATpat: SATPatHandle);
- {Sound}
- procedure SATSoundInit; {Called from InitSAT}
- procedure SATSoundPlay (TheSound: Handle; Priority: integer; CanWait: boolean);
- procedure SATSoundEvents; {Call this once in a while when not calling RunSAT often}
- procedure SATSoundShutup; {Silence, dispose of sound channel}
- procedure SATSoundOn;
- procedure SATSoundOff;
- function SATSoundDone: Boolean; {Any sound going on ?}
- function SATGetSound (sndId: integer): handle; { To load a sound and get a handle for SATSoundPlay }
- function SATGetNamedSound (name: Str255): Handle; { Same but using resource names }
- procedure SATDisposeSound (theSnd: handle);
- {Experimental, likely to be renamed/removed/changed:}
- procedure SATSoundPlay2 (theSound: Handle; priority: integer; canWait, skipIfSame: Boolean);
- procedure SATSoundPlayEasy (theSound: handle; canWait: boolean);
-
- implementation
- end.